#include "Game.h"
#include <sstream>
#include "Settings.h"

Game::Game()
{
    Window.Create(sf::VideoMode(WIDTH + 200, HEIGHT, 32), "X-Break");
    Window.SetFramerateLimit(100);
    Window.ShowMouseCursor(false);

    std::ifstream file;
    file.open("Data/settings.txt");
    file >> playMusic;
    file >> spaceBackground;
    file >> applause;
    file.close();

    stateManager = new sfge::StateManager;

    stateManager->changeState(MenuState::Instance(&Window, stateManager));

    icon.LoadFromFile("Data/Images/Ball.png");
    Window.SetIcon(icon.GetWidth(), icon.GetHeight(), icon.GetPixelsPtr());
    Window.EnableVerticalSync(false);
}

Game::~Game()
{
    //dtor
}

void Game::run()
{
    while(stateManager->running)
    {
        stateManager->update();
        stateManager->draw();
        stateManager->handle();
    }
    rm->releaseAll();

    Window.Close();
    return;
}
